package Scene1;

import Picture.GameImage;
import Scene1.Scene1;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.util.Stack;

public class GamePanel extends JPanel  {

    BufferedImage imgF = GameImage.get("/Picture/Scene1/ (1).png");
    BufferedImage imgP = GameImage.get("/Picture/Scene1/场景.png");
    public void reSize(Frame frame){
        frame.setSize(1536,1110);
    }
    public void changeFont(){

        imgF = scene1.stackFont.pop();

        repaint();
    }
    public void changeImage(){

        imgP = scene1.stackPic.pop();

        repaint();
    }
    Scene1 scene1 = new Scene1();
    Plant1 plant1 = new Plant1();
    public GamePanel(){



    }

    int flag = 0;



    public void paint(Graphics g) {
        super.paint(g);
        while (flag == 0) {
            Thread plant = new MyThread(g);
            plant.start();
            flag++;
        }

        g.drawImage(imgP, 0, 0, null);
        g.drawImage(scene1.map.get("npc"),-80,450,null);
        g.drawImage(scene1.map.get("聊天框"),250,800,null);
        g.drawImage(imgF,360,870,null);
        g.drawImage(scene1.map.get("箭头"),1200,970,null);



    }

        class MyThread extends Thread {
            Graphics g;
            int i = 1;

            public MyThread(Graphics g) {
                this.g = g;
            }

            public void run() {

                while (true) {
                    plant1.changeImage();

                    try {
                        repaint();
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }

        }


    }
